#pragma once

class ThreadRunner
{
public:
	class Controller
	{
	public:
		virtual bool IsCancelled() const = 0;
	};
	class Runnable
	{
	public:
		virtual void Run(Controller& controller) = 0;
	};
	~ThreadRunner();
	ThreadRunner(Runnable& runnable);
	void Start();
	void Stop();
private:
	HANDLE mThread;
	DWORD mThreadID;
	bool mCancelled;
	Runnable& mRunnable;

	static DWORD WINAPI ThreadProc(LPVOID lpParameter);
	DWORD ThreadProcImpl();

	ThreadRunner(const ThreadRunner&);
	void operator=(const ThreadRunner&);
};
